#include<stdio.h>

#define TIME_Addr  0xFFFFC0000                  //实时钟芯片的IO映像基址是OxFFFFC0000
#define TIME *(volatile int *) (TIME_Addr+2)    //时间存放在基址+2的寄存器中

void SetSeconds(int seconds)
{
    int oldtime=TIME;
    int newtime=oldtime&~0x1F;
    newtime|=seconds&0x1F;
    TIME=newtime;

}
int getSeconds()
{
    int time；
    time=time&0x1F;
    return time ；
}

void SetHours(int hours)
{
    int oldtime = TIME;
    int newtime = oldtime & ~ (0x1F << 11);
    newtime |= (hours & 0x1F) << 11;
    TIME = newtime;
}

int getHours()
{
    int time;
    time = (time>>11) & 0x1F;
    return time;
}
